import { legacy_createStore as createStore, applyMiddleware } from 'redux'

import app from './modules/app'
import pro from './modules/pro'

// createSagaMiddleware 用来创建 saga 的中间件
import createSagaMiddleware from 'redux-saga'
import mySaga from './mySaga'

// 原来合并 reducer 方法现在从 redux-immutable 进入导入
import { combineReducers } from 'redux-immutable'

// 创建一个中间件
const sagaMiddleware = createSagaMiddleware()

const reducer = combineReducers({
    app,
    pro
})

// 应用中间件
const store = createStore(reducer, applyMiddleware(sagaMiddleware))

// 使我们的 saga 生效
sagaMiddleware.run(mySaga)

export default store